package cn.laixueit.cart.controller;

import cn.laixueit.cart.pojo.item.SpecParams;
import cn.laixueit.cart.service.SpecParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;

@Controller
@RequestMapping("/spec")
public class SpecParamsController {

    @Autowired
    private SpecParamsService specParamsService;

    @GetMapping("/params")
    public ResponseEntity<Collection<SpecParams>> groups(@RequestParam(value = "gid",required = false) Long gid,
                                                         @RequestParam(value = "cid",required = false)Long cid,
                                                         @RequestParam(value = "searching",required = false)Boolean searching,
                                                         @RequestParam(value = "generic",required = false)Boolean generic){

        Collection<SpecParams> specparams = specParamsService.findSpecParams(gid,cid,searching,generic);
        return ResponseEntity.ok(specparams);
    }
}
